package com.ogawa.chair7808.ui.presenter;


import android.text.TextUtils;

import com.easepal.socketiolib.model.SocketModel;
import com.ogawa.base.Constant.CommmandNum;
import com.ogawa.chair7808.observer.SocketDataObserver;
import com.ogawa.chair7808.ui.iview.IFraAirView7506;

/**
 * Created by FHB on 2018/4/1.
 */

public class FraAirPresenter7506 implements SocketDataObserver.SocketReceive {
    IFraAirView7506 mView;

    public FraAirPresenter7506(IFraAirView7506 view) {
        mView = view;
        SocketDataObserver.getInst().registerObserver(this);

    }
    public void onDestory(){
        SocketDataObserver.getInst().removeObserver(this);
    }
    public void getAirPosition(String key,String value){
        if(!TextUtils.isEmpty(value)){
            if(key.equals(CommmandNum.mStatusAirShoulder)){
                mView.getAirPosition(0,Integer.valueOf(value));
            }
            else if(key.equals(CommmandNum.mStatusAirSit)){
                mView.getAirPosition(1,Integer.valueOf(value));
            }
            else if(key.equals(CommmandNum.mStatusAirHand)){
                mView.getAirPosition(2,Integer.valueOf(value));
            }
            else if(key.equals(CommmandNum.mStatusAirLeg)){
                mView.getAirPosition(3,Integer.valueOf(value));
            }
            else if(key.equals(CommmandNum.mStatusAirAll)){
                mView.getAirPosition(4,Integer.valueOf(value));
            }
            else if(key.equals(CommmandNum.mStatusAirStrong)){
                mView.getAirStrong(Integer.valueOf(value));
            }
        }

    }

    @Override
    public void onRceiveSocket(SocketModel model) {
        String key = model.getKey();
        String value = model.getValue();
        getAirPosition(key,value);

    }
}
